//
//  RecommendTypeCell.swift
//  Spookiness
//
//  Created by 腾億 on 2017/12/7.
//  Copyright © 2017年 tml. All rights reserved.
//

import UIKit

class RecommendTypeCell: UICollectionViewCell {
    
    fileprivate lazy var iconView: UIImageView = {
        let icon = UIImageView()
        icon.contentMode  = .scaleAspectFill
        icon.clipsToBounds = true
        return icon
    }()
    
    fileprivate lazy var titleLB: UILabel = {
       let title = UILabel()
        title.textColor = UIColor.black
        title.font = UIFont.systemFont(ofSize: 14)
        title.textAlignment = .center
        return title
    }()
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        self.contentView.addSubview(self.iconView)
        self.contentView.addSubview(self.titleLB)
        setUpSnap()
    }
    
    fileprivate func setUpSnap() {
        self.iconView.snp.makeConstraints { (make) in
            make.top.equalToSuperview().offset(10)
            make.centerX.equalToSuperview()
            make.width.height.equalTo(40)
        }
        
        self.titleLB.snp.makeConstraints { (make) in
            make.top.equalTo(self.iconView.snp.bottom)
            make.left.right.equalToSuperview().inset(UIEdgeInsetsMake(0, 10, 0, 10))
            make.height.equalTo(20)
        }
    }
    
    var typeModel: ComicsModel? {
        didSet {
            guard typeModel != nil else {
                return
            }
            iconView.kf.setImage(urlString: typeModel?.cover)
            titleLB.text = typeModel?.name
        }
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    
}
